<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
	<title>运行状态监控</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="../../css/style.css">
	<script type="text/javascript" src="../../js/jquery-1.8.2.js"></script>
	<script type="text/javascript" src="../../js/dialog/jquery.artDialog.source.js?skin=default"></script>
	<script type="text/javascript" src="../../js/dialog/plugins/iframeTools.source.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
	<script type="text/javascript" src="../../js/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.form.js"></script>
	<script type="text/javascript" src="../../js/jquery.page.js"></script>
	<script type="text/javascript" src="../../js/base.js"></script>
	<style type="text/css">
		.anchorBL{display:none;}
		.BMap_bubble_content p{clear:both;}
		.BMap_bubble_content p label{display:block;float:left;width:70px;text-align:left;}
		.BMap_bubble_content p span{display:block;float:left;}
		.view dt{width:19%}
		.view dd{width:30%}
		.view dd.giant{width:79%}
	</style>
</head>
<body class="app">
	<h3>运行状态监控</h3>
	<form class="search" name="search">
		<div class="tbdiv">
		<table>
			<tr>
				<th width="100">行政监管单位：</th>
				<td width="100"><select name="adminCode"></select></td>
				<th width="100">物业公司：</th>
				<td width="100"><select name="propertyCode"></select></td>
				<th width="100">维保单位：</th>
				<td><select name="serviceCode"></select></td>
			</tr>
			<tr>
				<th>电梯状态：</th>
				<td><select name="eleStatus" style="width:75px;"></select></td>
				<th>电梯ID：</th>
				<td colspan="3"><input type="text" class="inputText" name="eleCode" value="" style="width:110px;"/></td>
			</tr>
			<tr>
				<th>所属区域：</th>
				<td colspan="4">
					<input type="hidden" name="areaName" value=""/>
					<input type="text" class="inputText" name="areaNameN" value="" style="width:347px;*width:348px;cursor:pointer;" readonly="readonly" />
				</td>
				<td><input type="submit" value="查询" class="inputButton"/></td>
			</tr>
		</table>
		</div>
		
	</form>
	<div id="list"></div>
	<div class="areaTree"><div id="areaTree" class="ztree"></div></div>
	<div id="view" style="width:730px;display:none;">
		<dl class="view">
			<dt>ID：</dt>
			<dd><span id="watchId"></span></dd>
			<dt>电梯名称：</dt>
			<dd><span id="eleName"></span></dd>
			<dt>电梯号码：</dt>
			<dd><span id="eleCode"></span></dd>
			<dt>注册代码：</dt>
			<dd><span id="eleBasicRegNum"></span></dd>
			<dt>出厂日期：</dt>
			<dd><span id="leaveFactoryDate"></span></dd>
			<dt>电梯品牌：</dt>
			<dd><span id="eleTradeName"></span></dd>
			<dt>安装日期：</dt>
			<dd><span id="eleSetDate"></span></dd>
			<dt>电梯类型：</dt>
			<dd><span id="eleBasicStyle"></span></dd>
			<dt>制造单位：</dt>
			<dd><span id="produceUnit"></span></dd>
			<dt>电梯型号：</dt>
			<dd><span id="eleBasicType"></span></dd>
			<dt>所属区域：</dt>
			<dd><span id="areaname"></span></dd>
			<dt>地理位置：</dt>
			<dd>【<a href="javascript:void(0)" id="location">查看</a>】</dd>
			<dt>电梯底层：</dt>
			<dd><span id="eleGroundFloor"></span></dd>
			<dt>电梯顶层：</dt>
			<dd><span id="eleTopFloor"></span></dd>
			<dt>当前状态：</dt>
			<dd><span id="eleStatus"></span></dd>
			<dt>所在楼层：</dt>
			<dd><span id="localFloor"></span></dd>
			<dt>电梯门状态：</dt>
			<dd><span id="eleDoorStateText"></span></dd>
			<dt>运行速度：</dt>
			<dd><span id="moveSpeed"></span></dd>
			
			<dt>总运行次数：</dt>
			<dd>当前[<span id="eleCirculateTime"></span>]（限次[<span id="eleSumTime"></span>]）</dd>
			<dt>门机运行次数：</dt>
			<dd>当前[<span id="doorCirculateTime"></span>]（限次[<span id="doorSumTime"></span>]）</dd>
			<dt>制动器运行次数：</dt>
			<dd>当前[<span id="detentCirculateTime"></span>]（限次[<span id="detentSumTime"></span>]）</dd>
			<dt>主接触器运行次数：</dt>
			<dd>当前[<span id="mainContactCirTime"></span>]（限次[<span id="mainContactSumTime"></span>]）</dd>
			<dt>辅助接触器运行次数：</dt>
			<dd>当前[<span id="runContactCirTime"></span>]（限次[<span id="runContactSumTime"></span>]）</dd>
			<dt>钢丝绳折弯次数：</dt>
			<dd>当前[<span id="wireBendCirTime"></span>]（限次[<span id="wireBendSumTime"></span>]）</dd>
			<dt>有人乘梯：</dt>
			<dd><span id="bodyInductionText"></span></dd>
			<dt>监控时刻：</dt>
			<dd><span id="happenTime"></span></dd>
			<dt>使用单位：</dt>
			<dd class="giant"><span id="eleUseUnit"></span></dd>
			<dt>行政监管单位：</dt>
			<dd class="giant"><span id="adminName"></span> - 单位电话：<span id="adminPhone"></span></dd>
			<dt>物业单位：</dt>
			<dd class="giant"><span id="propertyName"></span> - 单位电话：<span id="propertyPhone"></span></dd>
			<dt>维保单位：</dt>
			<dd class="giant"><span id="serviceName"></span> - 单位电话：<span id="servicePhone"></span></dd>
			<div class="cl"></div>
		</dl>
	</div>
	<div id="container" style="width:560px;height:320px;display:none;"></div>
	<script type="text/javascript">
	setInterval("rlist()",10000);
	var rlist = function(){
		$('#list').page('show');
	}
	$(function(){
		$('#list').page({
			url:'yxztjk_search.action',
			param:{eleStatus:$.getUrlParam('eleStatus')},
			config:'pageinfo,record,first,last,next,prev,jump',
			items:[{
				title:'电梯号码',
				name:'eleCode'
			},{
				title:'电梯名称',
				name:'eleName'
			},{
				title:'当前状态',
				name:'eleCode',
				irender:function(row){
					var tArr = new Array();
					if(row.faultType == '0' && row.earlyWarning == '0' && row.beCheck == '0' && row.beRepaire == '0' && row.beFire == '0'){
						tArr.push('正常');
					}else{
						if(row.faultType > '0'){
							tArr.push('故障');
						}
						if(row.earlyWarning > '0'){
							tArr.push('预警');
						}
						if(row.beCheck > '0'){
							tArr.push('年检');
						}
						if(row.beRepaire > '0'){
							tArr.push('维保');
						}
						if(row.beFire > '0'){
							tArr.push('消防');
						}
					}
					row['eleStatus'] = tArr.join(',');
					return row.eleStatus;
				}
			},{
				title:'门状态',
				name:'eleDoorStateText'
			},{
				title:'方向',
				name:'moveStateText'
			},{
				title:'速度(m/s)',
				name:'moveSpeed'
			},{
				title:'人员',
				name:'bodyInductionText'
			},{
				title:'时间',
				name:'happenTime'
			},{
				title:'详情',
				render:function(row){
					$a = $('<a href="javascript:void(0)")">【详细】</a>');
					$a.click(function(){
						view(row);
					});
					return $a;
				}
			}]
		});

		$(document.search).ajaxForm({
			beforeSubmit:function(formData){
				var param = $(formData).formParam();
				$('#list').page('param',param);
				$('#list').page('show');
				return false;
			}
		});
		$('select[name=adminCode]').selectload('../../common/adminunit_select.action','adminCode','adminName');
		$('select[name=propertyCode]').selectload('../../common/propertyunit_select.action','propertyCode','propertyName');
		$('select[name=serviceCode]').selectload('../../common/serviceunit_select.action','serviceCode','serviceName');
		$('select[name=eleStatus]').selectload('../../common/code.action','code','codedesc',{codepid:'1'},false);
		$('select[name=eleStatus]').val($.getUrlParam('eleStatus'));
	});

	
	try {
		var point = new BMap.Point(116.404,39.915);
		var map = new BMap.Map('container');
		map.enableScrollWheelZoom();
		map.enableContinuousZoom();
		map.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_HYBRID_MAP]}));	//地图类型
		map.centerAndZoom(new BMap.Point(116.404,39.915), 20);
	} catch (e) {
		//alert('没有连接互联网');
	}
	var view = function(row){
		$('#view #watchId').html(row.watchId);
		$('#view #eleName').html(row.eleName);
		$('#view #eleCode').html(row.eleCode);
		$('#view #eleBasicRegNum').html(row.eleBasicRegNum);
		$('#view #leaveFactoryDate').html(row.leaveFactoryDate);
		$('#view #eleTradeName').html(row.eleTradeName);
		$('#view #eleSetDate').html(row.eleSetDate);
		$('#view #eleBasicStyle').html(row.eleBasicStyle);
		$('#view #produceUnit').html(row.produceUnit);
		$('#view #eleBasicType').html(row.eleBasicType);
		$('#view #areaname').html(row.areaname);
		$('#view #eleGroundFloor').html(row.eleGroundFloor);
		$('#view #eleTopFloor').html(row.eleTopFloor);
		$('#view #eleStatus').html(row.eleStatus);
		$('#view #localFloor').html(row.localFloor);
		$('#view #eleDoorStateText').html(row.eleDoorStateText);
		$('#view #moveSpeed').html(row.moveSpeed);
		
		$('#view #eleCirculateTime').html('<font color="'+(parseInt(row.eleCirculateTime)+parseInt(row.eleCirculateTimeCount) > parseInt(row.eleSumTime) ? "red":"")+'">'+(parseInt(row.eleCirculateTime)+parseInt(row.eleCirculateTimeCount))+'</font>');
		$('#view #eleSumTime').html(row.eleSumTime);

		$('#view #doorCirculateTime').html('<font color="'+(parseInt(row.doorCirculateTime)+parseInt(row.doorCirculateTimeCount) > parseInt(row.doorSumTime) ? "red":"")+'">'+(parseInt(row.doorCirculateTime)+parseInt(row.doorCirculateTimeCount))+'</font>');
		$('#view #doorSumTime').html(row.doorSumTime);
		
		$('#view #detentCirculateTime').html('<font color="'+(parseInt(row.detentCirculateTime)+parseInt(row.detentCirculateTimeCount) > parseInt(row.detentSumTime) ? "red":"")+'">'+(parseInt(row.detentCirculateTime)+parseInt(row.detentCirculateTimeCount))+'</font>');
		$('#view #detentSumTime').html(row.detentSumTime);
		
		$('#view #mainContactCirTime').html('<font color="'+(parseInt(row.mainContactCirTime)+parseInt(row.mainContactCirTimeCount) > parseInt(row.mainContactSumTime) ? "red":"")+'">'+(parseInt(row.mainContactCirTime)+parseInt(row.mainContactCirTimeCount))+'</font>');
		$('#view #mainContactSumTime').html(row.mainContactSumTime);
		
		$('#view #runContactCirTime').html('<font color="'+(parseInt(row.runContactCirTime)+parseInt(row.runContactCirTimeCount) > parseInt(row.runContactSumTime) ? "red":"")+'">'+(parseInt(row.runContactCirTime)+parseInt(row.runContactCirTimeCount))+'</font>');
		$('#view #runContactSumTime').html(row.runContactSumTime);
		
		$('#view #wireBendCirTime').html('<font color="'+(parseInt(row.wireBendCirTime)+parseInt(row.wireBendCirTimeCount) > parseInt(row.wireBendSumTime) ? "red":"")+'">'+(parseInt(row.wireBendCirTime)+parseInt(row.wireBendCirTimeCount))+'</font>');
		$('#view #wireBendSumTime').html(row.wireBendSumTime);
		
		$('#view #bodyInductionText').html(row.bodyInductionText);
		$('#view #happenTime').html(row.happenTime);
		$('#view #eleUseUnit').html(row.eleUseUnit);
		
		$('#view #adminName').html(row.adminName);
		$('#view #adminPhone').html(row.adminPhone);
		$('#view #propertyName').html(row.propertyName);
		$('#view #propertyPhone').html(row.propertyPhone);
		$('#view #serviceName').html(row.serviceName);
		$('#view #servicePhone').html(row.servicePhone);
		$('#view #location').click(function(){
			try {
				var marker = new BMap.Marker();
				marker.setPosition(new BMap.Point(row.eleLongitude,row.eleLatitude));
				map.addOverlay(marker);
				map.setCenter(new BMap.Point(row.eleLongitude,row.eleLatitude));
				map.panBy(280,160);
				$.dialog({
					id:'locationdialog',
					title:'电梯地理位置',
					lock:true,
					padding:'0px 0px',
					content:document.getElementById('container'),
					close:function(){
						marker.dispose();
					}
				});
			} catch (e) {
				alert('没有连接互联网');
			}
		});
		$.dialog({
			id:'viewdialog',
			title:'信息查看-运行状态监控',
			lock:true,
			width:'100%',
			height:'100%',
			content:document.getElementById('view')
		});
	}

	
	$(function(){
		$(document).mouseup(function(e){
			var $target = $(e.target);
			if(!$target.is('.areaTree')){
				if($target.parents('.areaTree').length == 0){
					$('.areaTree').hide();
				}
			}
		});
		
		//渲染区域树
		$.fn.zTree.init($('#areaTree'),{
			data: {
				key:{
					name:'areaname'
				},
				simpleData: {
					enable: true,
					idKey:'areacode',
					pIdKey:'parentcode',
					rootPId:0
				}
			},
			async: {
				enable: true,
				url:"../../common/area_tree.action",
				autoParam:["areacode"]
			},
			callback:{
				onClick:function(e,id,node){
					var oldnode = node;
					if(node.isParent == false){
						var $areaTree = $('.areaTree');
						var areaArr = new Array();
						areaArr.unshift(node.areaname);
						while(node.parentcode > 0){
							node = node.getParentNode();
							areaArr.unshift(node.areaname);
						}
						$('input[name=areaNameN]').val(areaArr.join(' > '));
						$('input[name=areaName]').val(oldnode.areacode);
						$areaTree.hide();
					}
				}
			}
		});
		
		//区域树
		$('input[name=areaNameN]').click(function(){
			$this = $(this);
			$hidden = $('input[name=areaName]');
			$areaTree = $('.areaTree');
			$this.val('');
			$hidden.val('');
			var os = $this.offset();
			$areaTree.css({left:os.left,top:os.top+($this.outerHeight(true)-1)});
			$areaTree.show();
		});
	});
	</script>
</body>
</html>
